/******************* 公共变量 *******************/
var userId = core.getUrlData('user_id');

/******************* Vue初始化代码 *******************/
var vm = new Vue({
	el: '.wrap',
	data: {
		phone: '',
		newPhone: '',
		code: ''
	},
	methods: {
		checkPhone: function () {
			!core.phoneJudge(this.newPhone) && core.layerHint('请输入正确手机号');
		},
		checkCode: function () {
			!core.securityCodeJudge(this.code) && core.layerHint('请输入6位数字验证码');
		},
		submit: function () {
			var _this = this;
			if (core.phoneJudge(this.newPhone)) {
				if (core.securityCodeJudge(this.code)) {
					$.ajax({
						url: phoneUrl,
						type: 'post',
						data: {
							mobile: _this.newPhone,
							sms_code: _this.code
						},
						success: function (data) {
							console.log(data)
							
							if (data.status == 1) {
								core.hintBack(data.info);
							} else {
								core.layerHint(data.info);
							}
						}
					});
				} else {
					core.layerHint('请输入6位数字验证码');
				}
			} else {
				core.layerHint('请输入正确手机号');
			}
		}
	},
	computed: {
		
	},
	components: {
		
	},
	created: function () {
		var _this = this;
		$.ajax({
			url: mobileUrl,
			type: 'post',
			success: function (data) {
				console.log(data)
				
				data.list.phone && (_this.phone = core.hideCenterPhoneNum(data.list.phone));
			}
		});
	},
	mounted: function () {
		var _this = this;
		common.bindBack();

		/******************* 获取验证码倒计时功能 *******************/
		var count = core.countDownTime({
			btn: 'html body .wrap .user-phone .set-phone div:nth-child(2) em',
			event: 'tap',
			// show: 'body .wrap .store-app .store-app-box .store-app-con form section span',
			textEnd: '发送',		// 倒计时结束时显示的文字
			countTime: 60000,		// 设定倒计时时间
			startAjax: function () {
				if (core.phoneJudge(_this.newPhone)) {
					return true;
				} else {
					core.layerHint('请输入正确手机号');
					return false;
				}
			},
			ajaxJudge: {
				url: codeUrl,
				type: 'post',
				data: function () {
					return {
						mobile: _this.newPhone
					};
				},
				success: function (data, count) {
					console.log(data)
					core.layerHint(data.info);
					if (data.status == 1) {
						count();
					}
				}
			}
		});
	},
	updated: function () {
		
	}
});